#include "Code5_DBL.h"

unsigned char DipMode = 0;	

#ifdef LED
const uint16_t Led[LED_NUM] = {LED1, LED2, LED3, LED4, LED5, LED6, LED7};		
#endif										
	 
#ifdef DIP
const uint16_t Dip[DIP_NUM] = {DIP1, DIP2, DIP3, DIP4, DIP5, DIP6};					
#endif											 

unsigned char ReadDip(void)
{			
	unsigned char dip_in = 0;
	int i;
	
	#ifdef DIP
	for(i=0; i < DIP_NUM; i++)
	{
		dip_in += (!GPIO_ReadInputDataBit(DIP_PORT, Dip[i])) * (1 << i); 
	}	
	#endif

	return dip_in;
}

void LedSwitch(WorkStatus status, int i)
{
	i--;

	#ifdef LED
	if((i >= 0) && (i < LED_NUM))
	{
		if(status == ON)
		{
			GPIO_SetBits(LED_PORT , Led[i]);
		}
		else
		{
			GPIO_ResetBits(LED_PORT , Led[i]);
		}
	}
	#endif
}

Bool GetLedStatus(int i)
{
	i--;

	#ifdef LED
	if((i >= 0) && (i < LED_NUM))
	{
		return GPIO_ReadOutputDataBit(LED_PORT , Led[i]);
	}
	#endif
	return FALSE;
}
